import { EntityBase } from 'ibiz-core';
import { IDynamicEntity } from '../interface';

/**
 * 动态实体基类
 *
 * @export
 * @abstract
 * @class DynamicEntityBase
 * @extends {EntityBase}
 * @implements {IDynamicEntity}
 */
export abstract class DynamicEntityBase extends EntityBase implements IDynamicEntity {
    /**
     * 实体名称
     *
     * @readonly
     * @type {string}
     * @memberof DynamicEntityBase
     */
    get srfdename(): string {
        return 'DYNAMICENTITY';
    }
    get srfkey() {
        return this.dynamicentityid;
    }
    set srfkey(val: any) {
        this.dynamicentityid = val;
    }
    get srfmajortext() {
        return this.dynamicentityname;
    }
    set srfmajortext(val: any) {
        this.dynamicentityname = val;
    }
    /**
     * 动态实体标识
     */
    dynamicentityid?: any;
    /**
     * 动态实体名称
     */
    dynamicentityname?: any;
    /**
     * 建立人
     */
    createman?: any;
    /**
     * 建立时间
     */
    createdate?: any;
    /**
     * 更新人
     */
    updateman?: any;
    /**
     * 更新时间
     */
    updatedate?: any;
    /**
     * 流程实例标识
     */
    wfinstanceid?: any;
    /**
     * 工作流状态
     */
    wfstate100?: any;
    /**
     * 业务状态
     */
    state?: any;
    /**
     * 步骤状态
     */
    wfstep?: any;

    /**
     * 重置实体数据
     *
     * @private
     * @param {*} [data={}]
     * @memberof DynamicEntityBase
     */
    reset(data: any = {}): void {
        super.reset(data);
        this.dynamicentityid = data.dynamicentityid || data.srfkey;
        this.dynamicentityname = data.dynamicentityname || data.srfmajortext;
    }
}
